import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _dec2, _class;

import React from 'react';
import { Bind } from 'lodash-decorators';
import { Col, Row, Timeline } from 'antd';
import styles from "./Notification.less?modules";
import temporarily from "../../../assets/cards/temporarily-no-data.svg";
var Notification = (_dec = Bind(), _dec2 = Bind(), (_class = /*#__PURE__*/function (_React$Component) {
  _inherits(Notification, _React$Component);

  var _super = _createSuper(Notification);

  function Notification() {
    _classCallCheck(this, Notification);

    return _super.apply(this, arguments);
  }

  _createClass(Notification, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var _this$props$handleUse = this.props.handleUserMessage,
          handleUserMessage = _this$props$handleUse === void 0 ? function (e) {
        return e;
      } : _this$props$handleUse;
      handleUserMessage('NOTICE');
    }
    /**
     * 点击跳转详情页
     * @param {number} number
     * @memberof System
     */

  }, {
    key: "handleSkip",
    value: function handleSkip(number) {
      var _this$props = this.props,
          _this$props$handleRea = _this$props.handleRead,
          handleRead = _this$props$handleRea === void 0 ? function (e) {
        return e;
      } : _this$props$handleRea,
          _this$props$handleDet = _this$props.handleDetails,
          handleDetails = _this$props$handleDet === void 0 ? function (e) {
        return e;
      } : _this$props$handleDet;
      handleRead(number, 'notice');
      handleDetails(number, 'notice');
    }
    /**
     * 设置消息数据展示
     * @param {object} item
     * @param {number} key
     * @memberof System
     */

  }, {
    key: "renderColor",
    value: function renderColor(item, key) {
      var _this = this;

      var colorObject = {
        0: '#0687ff',
        1: '#cb38ad',
        2: '#ffbc00',
        3: '#f02b2b'
      };
      return /*#__PURE__*/React.createElement(Timeline.Item, {
        key: item.messageId,
        color: colorObject[key % 4]
      }, /*#__PURE__*/React.createElement(Row, {
        className: styles['notification-row']
      }, /*#__PURE__*/React.createElement(Col, {
        span: 16,
        className: styles['notification-title'],
        onClick: function onClick() {
          return _this.handleSkip(item.userMessageId);
        }
      }, item.subject), /*#__PURE__*/React.createElement(Col, {
        span: 7,
        className: styles['notification-time'],
        onClick: function onClick() {
          return _this.handleSkip(item.userMessageId);
        }
      }, item.creationDate)));
    }
  }, {
    key: "render",
    value: function render() {
      var _this2 = this;

      var notificationList = this.props.notificationList;

      if (notificationList.length) {
        return /*#__PURE__*/React.createElement(Timeline, {
          className: styles['notification-overflow']
        }, notificationList.map(function (item, index) {
          return _this2.renderColor(item, index);
        }));
      } else {
        return /*#__PURE__*/React.createElement("div", {
          className: styles['notification-img-wrap']
        }, /*#__PURE__*/React.createElement("img", {
          src: temporarily,
          alt: "",
          className: styles['notification-img']
        }));
      }
    }
  }]);

  return Notification;
}(React.Component), (_applyDecoratedDescriptor(_class.prototype, "handleSkip", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "handleSkip"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "renderColor", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "renderColor"), _class.prototype)), _class));
export { Notification as default };